import { createWebHistory, createRouter } from "vue-router";
const routes = [
    { path: '/', redirect: '/home' },
    //主页路由
    { path: '/home', name: "home", meta: { title: "就业职通车" }, 
     component: () => import('@/pages/home.vue') },
    //招聘页路由
    { path: '/jobs', name: "jobs", meta: { title: "招聘岗位" }, 
     component: () => import('@/pages/jobs.vue') },
    //简历页路由
    { path: '/vitae', name: "vitae", meta: { title: "简历管理" }, 
     component: () => import('@/pages/vitae.vue') },
    //“我的”页路由
    { path: '/mine', name: "mine",  meta: { title: "我的" }, 
     component: () => import('@/pages/mine.vue') },
    { path: '/jobDetail/:id', name: "jobDetail",  meta: { title: "岗位详情" }, 
     component: () => import('@/pages/jobDetail.vue') },
     { path: '/login', name: "login",  meta: { title: "登录注册" }, 
     component: () => import('@/pages/login.vue') },
     { path: '/recode', name: "recode",  meta: { title: "投递记录" }, 
     component: () => import('@/pages/recode.vue') },
     { path: '/addvitae/:id?', name: "addvitae",  meta: { title: "简历管理" }, 
     component: () => import('@/pages/addVitae.vue') },
     { path: '/404', name: "404",  meta: { title: "未找到该页面" },
     component: () => import('@/pages/404.vue')},
     { path: '/:pathMatch(.*)*', redirect: "/404"},

]
const router = createRouter({
    history: createWebHistory(),
    routes: routes,
    linkActiveClass: 'active',
});
router.beforeEach((to, from, next) => {
    if (to.meta.title) { 
        document.title = to.meta.title
    }
    return next()
})
export default router